package com.lemon.typehandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import com.lemon.domain.Menu;

/**
 * 该类用于menu_mapper.xml中
 * 在插入语句中对
 * Menu的superiorMenu属性
 * 和数据库字段superior_menu_id
 * 进行映射
 */
public class MenuHandler extends BaseTypeHandler<Menu> {

	@Override
	public void setNonNullParameter(PreparedStatement ps, int i, Menu parameter, JdbcType jdbcType)
			throws SQLException {
		if (parameter != null) {
			ps.setLong(i, parameter.getId());
		} else {
			ps.setLong(i, -1);
		}
	}

	@Override
	public Menu getNullableResult(ResultSet rs, String columnName) throws SQLException {
		return null;
	}

	@Override
	public Menu getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
		return null;
	}

	@Override
	public Menu getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
		return null;
	}

}
